package com.rongdong.parkingcapture.client;

import com.rongdong.parkingcapture.domain.Task;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * kafka生产者
 */
@Service
public class KafkaProducer {

    @Resource
    private KafkaTemplate<String, Task> kafkaTemplate;

    public KafkaProducer(KafkaTemplate<String, Task> kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }


    public void sendMessage(String topic, Task task) {
        kafkaTemplate.send(topic, task);
    }
}
